public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
    public int uniquePaths(int m, int n) {
        int[][] dp=new int[m+1][n+1];
        dp[0][0]=0;
        for(int j=1;j<=n;j++){
            if(j==1){
                dp[0][j]=1;
            }else{
                dp[0][j]=0;
            }
        }
        for(int i=1;i<=m;i++){
            dp[i][0]=0;
        }
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
            }
        }
        return dp[m][n];
    }
    public int uniquePathsWithObstacles(int[][] obstacleGrid) {
        int[][] dp=new int[obstacleGrid.length+1][obstacleGrid[0].length+1];
        dp[0][1]=1;
        for(int i=1;i<=obstacleGrid.length;i++){
            for(int j=1;j<=obstacleGrid[0].length;j++){
                if(obstacleGrid[i-1][j-1]==1){
                    dp[i-1][j-1]=0;
                    continue;
                }
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
            }
        }
        return dp[obstacleGrid.length][obstacleGrid[0].length];
    }
}